﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using 纸片人.ConvertClass;
using 纸片人.win2dEffectControl.DataClass;
using 纸片人.CalculateControls;
// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235

namespace 纸片人.win2dEffectControl
{
    public sealed class EdgeDetectionEffectControl : EffectControl
    {

        ComboBox modeComboBox;
        ComboBox alphaModeComboBox;
        CheckBox overlayEdgesComboBox;
        TextBoxSlider amountTextBoxSlider;
        TextBoxSlider blurAmountTextBoxSlider;
        public override EffectOneSourceData OneEffetData { get; set; }

        List<CanvasAlphaMode> listCanvasAlphaMode = new List<CanvasAlphaMode>();
        List<EdgeDetectionEffectMode> listEdgeDetectionEffectMode = new List<EdgeDetectionEffectMode>();

        public EdgeDetectionEffectControl()
        {
            this.DefaultStyleKey = typeof(EdgeDetectionEffectControl);
            listCanvasAlphaMode = EffectUtil.GetEnumList<CanvasAlphaMode>();
            listEdgeDetectionEffectMode = EffectUtil.GetEnumList<EdgeDetectionEffectMode>();
            OneEffetData = new EdgeDetectionEffectData();
        }

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            SetEffectName("检测边缘效果", "EdgeDetectionEffect");

            modeComboBox = GetTemplateChildFormName<ComboBox>(nameof(modeComboBox));
            SetComboBox(modeComboBox, listEdgeDetectionEffectMode, OneEffetData, nameof(EdgeDetectionEffectData.Mode));

            alphaModeComboBox = GetTemplateChildFormName<ComboBox>(nameof(alphaModeComboBox));
            SetComboBox(alphaModeComboBox, listCanvasAlphaMode, OneEffetData, nameof(EdgeDetectionEffectData.AlphaMode));

            overlayEdgesComboBox = GetTemplateChildFormName<CheckBox>(nameof(overlayEdgesComboBox));
            SetCheckBox(overlayEdgesComboBox, OneEffetData, nameof(EdgeDetectionEffectData.OverlayEdges));

            amountTextBoxSlider = GetTemplateChildFormName<TextBoxSlider>(nameof(amountTextBoxSlider));
            SetTextBoxSlider(amountTextBoxSlider, OneEffetData, nameof(EdgeDetectionEffectData.Amount));

            blurAmountTextBoxSlider = GetTemplateChildFormName<TextBoxSlider>(nameof(blurAmountTextBoxSlider));
            SetTextBoxSlider(blurAmountTextBoxSlider, OneEffetData, nameof(EdgeDetectionEffectData.BlurAmount));

        }

    }
}
